(function ($) {
  Drupal.behaviors.contextExtendShowRegions = {
    attach: function() {
      $(function() {
        // Append the link and add click handler to reload the page.
        $('.context-extend-show-regions').click(function(e){
          if (Drupal.settings.context_extend.isShown == false) {
            $('.region').addClass('show-border');
            var text = Drupal.t('Hide regions');
            Drupal.settings.context_extend.isShown = true;
          }
          else {
            $('.region').removeClass('show-border');
            var text = Drupal.t('Show regions');
            Drupal.settings.context_extend.isShown = false;
          }
          $(this).html(text);
          e.preventDefault();
          return false;
        });
      });
    },
    detach: function() { }
  };
})(jQuery);
